function drawKline(t, e, a, i) {
    //隐藏loading img
    $('#il_img').hide();

    function n(t) {
        var e = 10 * Math.random() * (Math.random() - .5) - 10,
            a = t + e;
        return a = 100 > a ? b : a, b = a, a;
    }
    var o = this,
        r = [],
        l = 0,
        s = [],
        h = t.length,
        c = [
            ["week", [1]],
            ["month", [1, 2, 3, 4, 6]]
        ],
        m = ["#e4462e", "#55a500"],
        p = [],
        u = [];
    for (l; h > l; l += 1) {
        var d = (t[l][0], t[l][1]),
            g = (t[l][2], t[l][3], t[l][4]),
            f = 0,
            x = 0;
        t[l - 1] ? (f = g - t[l - 1][4], 0 == f ? (f = 0, x = 0) : x = f / t[l - 1][4] * 100) : (f = g - d, x = f / d * 100, console.info(g, d, f)),
            r.push({
                x: t[l][0],
                y: t[l][1],
                open: t[l][1],
                high: t[l][2],
                low: t[l][3],
                close: t[l][4],
                change: f,
                change_percent: x,
                volume: t[l][5],
                ma5: 12.25 + l,
                ma10: 35.54 + l,
                ma20: 25.65 + l,
                ma30: 31.31 + l,
                kline: !0
            }),
            s.push({ x: t[l][0], y: t[l][5], color: g > d ? m[0] : m[1] }), p.push([t[l][0], n(t[l][3])]), u.push([t[l][0], n(t[l][3])]);
    }
    var b = 0,
        y = $(".stock_info").find("span");
    Highcharts.setOptions({
            global: { useUTC: !1 }
        }),
        Highcharts.setOptions({
            lang: {
                downloadJPEG: "下载JPGE格式",
                contextButtonTitle: "hello",
                rangeSelectorFrom: "日期:",
                rangeSelectorTo: "至",
                rangeSelectorZoom: "范围",
                loading: "加载中...",
                shortMonths: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
                weekdays: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
            }
        }),
        $("#" + e + '_chart').highcharts("StockChart", {
                chart: {
                    style: {
                        fontFamily: '"Helvetica Neue", Arial, "Microsoft YaHei"',
                        fontSize: "12px"
                    },
                    animation: !1,
                    panning: !1
                },
                credits: {
                    enabled: false,
                },
                scrollbar: {
                    enabled: false,
                    liveRedraw: !1
                },
                rangeSelector: {
                    enabled: false,
                    selected: i,
                    buttons: a,
                    inputEnabled: !1,
                    inputDateFormat: "%Y-%m-%d",
                    inputStyle: { color: "#1f1f1f", fontWeight: "bold" },
                    labelStyle: { color: "#0b1318", fontWeight: "bold" }
                },
                navigator: {
                    enabled: true,
                    xAxis: {
                        showLastLabel: false,
                        labels: {
                            formatter: function() {
                                return Highcharts.dateFormat("%Y-%m-%d", this.value);
                            }
                        }
                    }
                },
                title: { text: "" },
                tooltip: {
                    borderColor: "#dfdfdf",
                    useHTML: !0,
                    formatter: function() {
                        var t = this.points;
                        if (t && t.length) {
                            var e = t[0].point,
                                a = o.formatDecimal(e.open),
                                i = o.formatDecimal(e.high),
                                n = o.formatDecimal(e.low),
                                r = o.formatDecimal(e.close),
                                l = o.formatDecimal(e.volume),
                                s = o.formatDecimal(e.change),
                                h = o.formatDecimal(e.change_percent) + "%",
                                c = o.formatDecimal(e.ma5),
                                m = o.formatDecimal(e.ma10),
                                p = o.formatDecimal(e.ma20),
                                u = o.formatDecimal(e.ma30),
                                d = '<b style="line-height: 25px;">' + Highcharts.dateFormat("%Y-%m-%d  %A", this.x) + "</b><br/>";
                            return d += '开盘价：<span style="line-height: 25px;">' + a + " </span><br/>",
                                d += '最高价：<span style="line-height: 25px;">' + i + " </span><br/>",
                                d += '最低价：<span style="line-height: 25px;">' + n + " </span><br/>",
                                d += '收盘价：<span style="line-height: 25px;">' + r + " </span><br/>",

                                0 > s

                                ?
                                (d += '涨跌额：<span style="color: #3A1;line-height: 25px;">' + s + "</span><br/>",
                                    d += '涨跌幅：<span style="color: #3A1;line-height: 25px;">' + h + "</span><br/>")

                            : (d += '涨跌额：<span style="color: #D20;line-height: 25px;">' + s + "</span><br/>",
                                d += '涨跌幅：<span style="color: #D20;line-height: 25px;">' + h + "</span><br/>"),

                            d += '成交量：<span style="line-height: 25px;">' + l + "万</span>",
                                y.eq(0).text(c), y.eq(1).text(m), y.eq(2).text(p), y.eq(3).text(u), d;
                        }
                    }
                },
                plotOptions: {
                    candlestick: {
                        color: "#3A1",
                        upColor: "#D20",
                        lineColor: "#3A1",
                        upLineColor: "#D20",
                        dataGrouping: { enabled: !1 }
                    },
                    line: {
                        marker: {
                            enabled: !1
                        },
                        lineWidth: 1,
                        state: {
                            hover: { enabled: !1 }
                        },
                        enableMouseTracking: !1
                    },
                    column: {
                        state: {
                            hover: { enabled: !1 }
                        },
                        enableMouseTracking: !1,
                        turboThreshold: Number.MAX_VALUE,
                        dataGrouping: { enabled: !1 }
                    },
                    series: {
                        turboThreshold: Number.MAX_VALUE
                    }
                },
                xAxis: {
                    type: "datetime",
                    gridLineWidth: 1,
                    gridLineColor: "#F0F0F0",
                    offset: -32,
                    tickWidth: 0,
                    lineWidth: 0,
                    labels: {
                        formatter: function() {
                            return Highcharts.dateFormat("%m-%d", this.value);
                        }
                    }
                },
                yAxis: [{
                        labels: {
                            align: "right",
                            x: 28
                        },
                        title: { text: " " },
                        height: 160,
                        offset: -40,
                        gridLineColor: "#F0F0F0",
                        tickPixelInterval: 40,
                        tickPositioner: function() {
                            var t = [],
                                e = Math.floor(this.dataMin),
                                a = Math.ceil((this.dataMax - this.dataMin) / 6);
                            for (e; e - a <= this.dataMax; e += a)
                                t.push(e);
                            return t;
                        }
                    },
                    {
                        gridLineColor: "#F0F0F0",
                        labels: {
                            align: "right",
                            x: 28,
                            formatter: function() {
                                function t(t, e) {
                                    return parseInt(Math.round(t / e));
                                }
                                var e = this.value,
                                    a = e,
                                    i = e.toString().length;
                                return e == 0 ? '万' : e;
                            }
                        },
                        title: { text: " " },
                        top: 190,
                        height: 40,
                        offset: -40,
                        tickPositioner: function() {
                            for (var t = [], e = Math.floor(this.dataMin), a = Math.ceil((this.dataMax - this.dataMin) / 3), i = 0; 4 > i; i++)
                                t.push(e), e += a;
                            return t;
                        }
                    }
                ],
                series: [{
                        type: "candlestick",
                        name: "AAPL",
                        data: r,
                        dataGrouping: { units: c }
                    },
                    {
                        type: "column",
                        name: "成交量",
                        data: s,
                        yAxis: 1,
                        dataGrouping: { units: c }
                    }
                ]
            },
            function() {
                setTimeout(function() {}, 0);
            });
}

function formatDecimal(t, e) {
    return e = e || 2, t ? t && t.toFixed(e) : 0..toFixed(e);
}